package com.example.q_kang.hhh.setting;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.example.q_kang.hhh.R;
import com.sskj.base.MVPFragment;
import com.sskj.base.utils.ClickUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * @author Hey
 * Create at  2019/04/18
 */
public class WelfareFragment extends MVPFragment<WelfarePresenter> {
    @BindView(R.id.btn_submit)
    Button btnSubmit;
    @BindView(R.id.rb_parallel)
    RadioButton rbParallel;
    @BindView(R.id.rb_down)
    RadioButton rbDown;
    @BindView(R.id.radioGroup)
    RadioGroup radioGroup;
    private int type;

    @Override
    public int getLayoutId() {
        return R.layout.fragment_welfare;
    }

    @Override
    public WelfarePresenter getPresenter() {
        return new WelfarePresenter();
    }

    @Override
    public void initView() {
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                switch (i) {
                    case R.id.rb_down:
                        type = 1;
                        break;
                    case R.id.rb_parallel:
                        type = 0;
                        break;
                }
            }
        });
        ClickUtil.click(300, btnSubmit, view -> {
            mPresenter.branchChange(type);
        });
    }


    @Override
    public void initData() {

    }


    public static WelfareFragment newInstance() {
        WelfareFragment fragment = new WelfareFragment();
        Bundle bundle = new Bundle();
        fragment.setArguments(bundle);
        return fragment;
    }
}
